#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[]) 
{
	int a,b,c,d;
	scanf("%d%d",&a,&b);
	c=1;
	for(int i=1;i<=b;i++)
	{
		c=c*a%1000;
		
	}
	
	if(c==0)
		printf("The last 3 numbers is 000.\n");
	
	else printf("The last 3 numbers is %d.\n",c);
	
}